<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class IntegralRecord extends Model
{
    use HasFactory;

    protected $fillable = ['user_id', 'income_type', 'integral_type', 'detail'];



    /**
     * Prepare a date for array / JSON serialization.
     *
     * @param  \DateTimeInterface  $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    public function users() {
        return $this->belongsTo(User::class, 'user_id');
    }


    public function intergralabel()
    {
        return $this->belongsTo(Dicdata::class, 'integral_type', 'value')
            ->where('typeCode', '=', 'inte_type');
    }
}
